<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <div th:include="common/css::css"></div>
</head>
<script>
    function abc(){
        var age = document.getElementById("age").value;
        var file = document.getElementById("file").value;
        if(age===""){
            age=0;
        }
        document.getElementById("age").value=age;
        console.log(file);
        if(file===""){
            alert("头像图片必须上传");
            return false;
        }else{
            return true
        }
    }
</script>
<body>
<!-- loader Start -->
<div id="loading" style="display: none;">
    <div id="loading-center">
    </div>
</div>
<!-- loader END -->
<!-- Wrapper Start -->
<div class="wrapper">
    <div th:include="common/top :: top"></div>
    <div th:include="common/left :: left(activeUrl='studnet',Url='list')"></div>
    <div id="content-page" class="content-page">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <div class="iq-card">
                        <div class="iq-card-body p-0">
                            <div class="tab-pane fade active show" id="personal-information" role="tabpanel">
                                <div class="iq-card">
                                    <div class="iq-card-header d-flex justify-content-between">
                                        <div class="iq-header-title">
                                            <h4 class="card-title">学生信息</h4>
                                        </div>
                                    </div>
                                    <div class="iq-card-body">
                                        <form th:action="@{/student/add}" enctype="multipart/form-data" method="post">
                                            <div class="form-group">
                                                <div class="add-img-user profile-img-edit">
                                                    <img class="profile-pic img-fluid" th:src="@{/images/user/11.png}" alt="profile-pic">
                                                    <div class="p-image">
                                                        <a href="#" class="upload-button btn iq-bg-primary">File Upload</a>
                                                        <input class="file-upload" id="file" name="file" type="file">
                                                    </div>
                                                </div>
                                                <div class="img-extension mt-3">
                                                    <div class="d-inline-block align-items-center">
                                                        <span>Only</span>
                                                        <a href="#">.jpg</a>
                                                        <a href="#">.png</a>
                                                        <a href="#">.jpeg</a>
                                                        <span>allowed</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class=" row align-items-center">
                                                <div class="form-group col-sm-6">
                                                    <label for="fname">姓名:</label>
                                                    <input type="text" class="form-control" id="fname" name="name">
                                                    <p style="color: red" th:if="${#fields.hasErrors('student.name')}" th:errors="${student.name}"></p>
                                                </div>
                                                <div class="form-group col-sm-6">
                                                    <label for="lname">专业班级:</label>
                                                    <input type="text" class="form-control" id="lname" name="majorClass">
                                                    <p style="color: red" th:if="${#fields.hasErrors('student.majorClass')}" th:errors="${student.majorClass}"></p>
                                                </div>
                                                <div class="form-group col-sm-6">
                                                    <label for="aname">专业全称</label>
                                                    <input type="text" class="form-control" id="aname" name="major">
                                                    <p style="color: red" th:if="${#fields.hasErrors('student.major')}" th:errors="${student.major}"></p>
                                                </div>
                                                <div class="form-group col-sm-6">
                                                    <label for="uname">学号:</label>
                                                    <input type="text" class="form-control" id="uname" name="stuNumber">
                                                    <p style="color: red" th:if="${#fields.hasErrors('student.stuNumber')}" th:errors="${student.stuNumber}"></p>
                                                </div>
                                                <div class="form-group col-sm-6">
                                                    <label for="cname">宿舍地址:</label>
                                                    <input type="text" class="form-control" id="cname" name="dormNumber">
                                                    <p style="color: red" th:if="${#fields.hasErrors('student.dormNumber')}" th:errors="${student.dormNumber}"></p>
                                                </div>
                                                <div class="form-group col-sm-6">
                                                    <label for="age">年龄:</label>
                                                    <input type="text" class="form-control" id="age" name="age">
                                                    <p style="color: red" th:if="${#fields.hasErrors('student.age')}" th:errors="${student.age}"></p>
                                                </div>
                                                <div class="form-group col-sm-6">
                                                    <label class="d-block">性别:</label>
                                                    <div class="custom-control custom-radio custom-control-inline">
                                                        <input type="radio" id="customRadio6" name="sex" value="男" class="custom-control-input" checked="">
                                                        <label class="custom-control-label" for="customRadio6"> 男 </label>
                                                    </div>
                                                    <div class="custom-control custom-radio custom-control-inline">
                                                        <input type="radio" id="customRadio7" name="sex" value="女" class="custom-control-input">
                                                        <label class="custom-control-label" for="customRadio7"> 女 </label>
                                                    </div>
                                                </div>
                                                <div class="col-md-12">
                                                    <div class="form-group">
                                                        <label for="dob">入学日期:</label>
                                                        <input type="date" class="form-control" id="dob" name="stuDay">
                                                        <p style="color: red" th:if="${#fields.hasErrors('student.stuDay')}" th:errors="${student.stuDay}"></p>
                                                    </div>
                                                </div>
                                            </div>
                                            <button type="submit" class="btn btn-primary mr-2" onclick="return abc()">提交</button>
                                            <button type="reset" class="btn iq-bg-danger">重置</button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="common/js::js"></div>
</body>
</html>